package com.lagou.spi.filter;

import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

/**
 * Dubbo过滤器实例-IP传输过滤器
 * @autor yzh
 * @date 2020/4/11 17:21
 */
@Activate(group = {CommonConstants.PROVIDER})
public class TransportIPFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        RpcContext.getContext().set("CLIENT_IP", RpcContext.getContext().getAttachment("CLIENT_IP"));
        return invoker.invoke(invocation);
    }
}
